home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7952 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  46 lines

  1. Path: news.ichange.com!newsmaster
  2. From: Jesse Liberty <jl@staff.ichange.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Please please help a newbie!
  5. Date: Thu, 15 Feb 1996 10:07:09 -0500
  6. Organization: AT&T
  7. Message-ID: <31234C1D.7712@staff.ichange.com>
  8. References: <4ftoe8$5a2@pacifica.access.ch> <31232DBE.5A69@staff.ichange.com> <31233ED0.5B2E@staff.ichange.com>
  9. NNTP-Posting-Host: 140.244.99.60
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (Win95; I)
  14. CC: jl@staff.ichange.com
  15.  
  16. Well,I'm having a heck of a time, neither my mailer nor my brain is 
  17. working.  The problem with your example was NOT what I said (of course 
  18. you CAN declare the variables external to main -- whatever was I 
  19. thinking), nor did my correction come through correctly due to the 
  20. mailer screwing up.  
  21.  
  22. Let's try again.
  23.  
  24. First, the original problem is that you have a .c extension on your file 
  25. and your compiler is probably treating it as a c program and not a c++ 
  26. program. Thus it is complaining about your reference, which is not a 
  27. construct that c understands.  Try changing the file to .cpp.
  28.  
  29. Second, there is no reason to make your int and int ref external to 
  30. main, you probably mean to write:
  31.  
  32.  
  33.  main()
  34.  {
  35.  int i;
  36.  int & a=i;
  37.  }
  38.  
  39. In a c++ program, that will compile (thought it won't do much).  
  40.  
  41.  
  42.  
  43. -- 
  44. Jesse Liberty    jl@staff.ichange.com
  45. AT&T             CIS: 72241,72
  46.